/* Copyright Homeaway, Inc 2005-2008. All Rights Reserved.
 * No unauthorized use of this software.
 */
package org.mis6323.data.dao.impl;

import org.apache.ibatis.session.SqlSession;
import org.mis6323.data.dao.PatientDao;
import org.mis6323.data.model.Patient;
import org.springframework.stereotype.Component;

@Component
public class DatabasePatientDaoImpl implements PatientDao{
    
    SqlSession sqlSession;

    public void setSqlSession(SqlSession session) {
        this.sqlSession = session;
    }

    public void createPatient(Patient patient) {
        this.sqlSession.insert("insertPatient", patient);
    }

    public void deletePatient(Long patientId) {
        //connect to database
        // run this query "Delete from Patient where id = patientId
        this.sqlSession.delete("deletePatient", patientId);
    }

    public void updatePatient(Patient patient) {
        //To change body of implemented methods use File | Settings | File Templates.
        this.sqlSession.update("updatePatient",patient);
    }

    public Patient searchPatientById(Long patientId) {
        return (Patient) this.sqlSession.selectOne("selectPatientById",patientId);
    }

    public Patient searchPatientByPhoneNo(String phoneNo) {
        return (Patient)  this.sqlSession.selectOne("selectPatientByPhoneNo",phoneNo);
    }
}

